import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { Conversation } from './conversation.entity';
import { User } from '../users/users.entity';

@Entity('conversation_participants')
export class ConversationParticipant {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ name: 'visitor_user_id' })
  visitorUserId: number;

  @Column({ name: 'visited_user_id' })
  visitedUserId: number;

  @CreateDateColumn({ name: 'visited_at' })
  visitedAt: Date;

  @ManyToOne(() => Conversation)
  @JoinColumn({ name: 'conversation_id' })
  conversation: Conversation;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'visitor_user_id' })
  visitorUser: User;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'visited_user_id' })
  visitedUser: User;
}
